﻿@inherits RazorFunction

@functions {
    public override string FunctionDescription
    {
        get { return "Contains search form: input textbox and submit button"; }
    }

    [FunctionParameter(Label = "Search Result Page", Help = "Select the page where search results will be displayed. This should be a page which contains the 'Search Results' function.")]
    public DataReference<Composite.Data.Types.IPage> SearchResultPage { get; set; }
    
    [FunctionParameter(Label = "Search Button Label", Help = "Label for search button", DefaultValue = "")]
    public string SearchButtonLabel { get; set; }
}
@{
    var pageNode = Data.SitemapNavigator.GetPageNodeById((Guid)SearchResultPage.KeyValue);

    if (pageNode == null)
    {
        return;
    }
}

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://www.composite.net/ns/function/1.0">
<head>
</head>
<body>
    <form id="SearchForm" action="@pageNode.Url" class="search-form form-inline"  method="get" role="search">
        <div class="form-group">
            <input type="text" class="form-control" placeholder="Search" id="searchText" name="q" value="@Request.QueryString["q"]" />
        </div>
        <button type="submit" class="btn btn-default">
			@if(string.IsNullOrEmpty(@SearchButtonLabel))
			{
				<span class="glyphicon glyphicon-search"></span>
			}
			else
			{
				@SearchButtonLabel			
			}
		</button>
    </form>
</body>
</html>